home *** CD-ROM | disk | FTP | other *** search
/ Sun Solutions 1997 April to September / Sun Solutions CD - APR '97 - SEP '97 (704-3778-12 Rev. H)(Sun Microsystems, Inc.)(1997).iso / products / bin / httpd / Solaris_x86 / catIPX.sol2 < prev    next >
Text File  |  1995-10-20  |  5KB  |  177 lines

  1. #!/bin/csh 
  2. # below is a scrpit launched by catIPX.pl from CDware 
  3. # It ultimately generates a query page to be 
  4. # displayed by the cgi-bin/catIPX.pl script.
  5. # Jun 6, 1995 Marc Sacoolas
  6.  
  7. setenv ONLY_ONE spam
  8.  
  9. set testdrvflg = 0
  10. set installflg = 0
  11. set osflg = 0
  12.  
  13. #
  14. # Get search string, filter-type and category
  15. #
  16.  
  17. set keyword = `awk -F^ '{ print $1 }' /tmp/httpd/tmp `
  18. set install = `awk -F^ '{ print $2 }' /tmp/httpd/tmp `
  19. set testdrive = `awk -F^ '{ print $3 }' /tmp/httpd/tmp `
  20. set ostype = `awk -F^ '{ print $4 }' /tmp/httpd/tmp | sed 's/ //g'`
  21.  
  22. # clear temporary files 
  23.  
  24. rm /tmp/httpd/tmppage.html
  25. #touch /tmp/httpd/tmppage.html
  26. rm /tmp/httpd/top
  27. touch /tmp/httpd/top
  28.  
  29. #
  30. # goto index.html directory and grep files for keyword --main list
  31. #
  32.  
  33. cd ../../../../.products
  34.  
  35.  
  36. foreach dir (`ls`)
  37.  
  38. if ( $dir == "hotjava" || $dir == "tmp" || $dir == "CDware" )  next 
  39.  
  40. # set flags for filters
  41. if ( $ostype != "OSType" ) then 
  42.  
  43.         set osflg = ` nawk -F^ ' BEGIN {} { if (NR == 2) exit; if ( $3 ~ /'"$ostype"'/ ) {print "0"} else {print "1"} }' $dir/_info `
  44.  
  45. endif 
  46.   
  47.  
  48. if ( $testdrive == "testdrive" ) then
  49.  
  50.         set testdrvflg = ` awk -F^ ' BEGIN {} { if (NR == 2) exit; if ( $3 ~ /'"$testdrive"'/ ) {print "0"} else {print "1"} }' $dir/_info `
  51.  
  52. endif    
  53.  
  54.  
  55. if ( $install == "install" ) then 
  56.  
  57.         set installflg = ` awk -F^ ' BEGIN {} { if (NR == 2) exit; if ( $3 ~ /'"$install"'/ ) {print "0"} else {print "1"} }' $dir/_info `
  58.  
  59. endif
  60.  
  61. # check to see if a blank query is given - make it *all*
  62.  
  63.  
  64. if ( $keyword == "ALL" && $installflg == "0" && $testdrvflg == "0" && $osflg == "0") then
  65.  
  66.  
  67. # read in company name and log
  68.  
  69. nawk -F^ ' { if (NR == 1) { \
  70. print ""$1"^"$2"^'"$dir"'^"} \
  71. }' $dir/_info  >> /tmp/httpd/top 
  72.  
  73. endif
  74.  
  75. set testdrvflg = 0
  76. set installflg = 0
  77.  
  78. end
  79.  
  80. sort -o /tmp/httpd/top.sort /tmp/httpd/top 
  81.  
  82. cd ../.products/.bin/httpd/cgi-bin
  83.  
  84. # see if *filter* exists
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93. #
  94. # creat new page based on resource file generated above 
  95. #
  96.  
  97.  
  98. if ( -z /tmp/httpd/top.sort ) then
  99. cat head.html > /tmp/httpd/tmppage.html
  100.     echo "<p><hr><center>" >> /tmp/httpd/tmppage.html
  101.     echo "<h1>Your search produced no results</H1>" >> /tmp/httpd/tmppage.html
  102.     echo "<h2><p>Try again, or use category, company, or product listings.</H1>" >> /tmp/httpd/tmppage.html
  103.     echo "<p></center>" >> /tmp/httpd/tmppage.html
  104.     echo '<app class=delay sound="./main.au" img="../../../CDware/images/comp-prod/clear.gif" del="4800" href="http://localhost:7999/CDware"> ' >> /tmp/httpd/tmppage.html
  105.  
  106. else 
  107.  
  108. cat head.html > /tmp/httpd/tmppage.html
  109.  
  110. # get number of answers and print
  111. set return = `grep -c ^ /tmp/httpd/top`
  112.  
  113. # if only one reslut, go there
  114.  
  115. if ( $return == 1 ) then
  116.  
  117. touch /tmp/httpd/only_one
  118. exit 0
  119.  
  120. endif
  121.  
  122.  
  123. if ( $return == 1 ) then
  124. set booths = "Company."
  125. else
  126. set booths = "Companies."
  127. endif
  128. echo "<I> Your search for  </i>'<B>$keyword</B>' <I>produced  </I><B>$return</B> <I> $booths</I>" >> /tmp/httpd/tmppage.html
  129. echo "<p>" >> /tmp/httpd/tmppage.html
  130.  
  131. # make main txt
  132.  
  133. echo "</pre>" >> /tmp/httpd/tmppage.html
  134. echo "<DL>" >> /tmp/httpd/tmppage.html
  135. echo '<hr>' >> /tmp/httpd/tmppage.html
  136. echo '<p>' >> /tmp/httpd/tmppage.html
  137.  
  138. # only include if over some ammount
  139. if ( $return >= 2 ) then 
  140. echo '<B><FONT size="-1">' /tmp/httpd/tmppage.html
  141. echo '<B>Search for--</b><A HREF="/tmp/httpd/tmppage.html#A">A</A> <A HREF="/tmp/httpd/tmppage.html#B">B</A> <A HREF="/tmp/httpd/tmppage.html#C">C</A> <A HREF="/tmp/httpd/tmppage.html#D">D</A>' >> /tmp/httpd/tmppage.html
  142. echo '<A HREF="/tmp/httpd/tmppage.html#E">E</A> <A HREF="/tmp/httpd/tmppage.html#F">F</A> <A HREF="/tmp/httpd/tmppage.html#G">G</A> <A HREF="/tmp/httpd/tmppage.html#H">H</A>' >> /tmp/httpd/tmppage.html
  143. echo '<A HREF="/tmp/httpd/tmppage.html#I">I</A> <A HREF="/tmp/httpd/tmppage.html#J">J</A> <A HREF="/tmp/httpd/tmppage.html#K">K</A> <A HREF="/tmp/httpd/tmppage.html#L">L</A>' >> /tmp/httpd/tmppage.html
  144. echo '<A HREF="/tmp/httpd/tmppage.html#M">M</A> <A HREF="/tmp/httpd/tmppage.html#N">N</A> <A HREF="/tmp/httpd/tmppage.html#O">O</A> <A HREF="/tmp/httpd/tmppage.html#P">P</A>' >> /tmp/httpd/tmppage.html
  145. echo '<A HREF="/tmp/httpd/tmppage.html#Q">Q</A> <A HREF="/tmp/httpd/tmppage.html#R">R</A> <A HREF="/tmp/httpd/tmppage.html#S">S</A> <A HREF="/tmp/httpd/tmppage.html#T">T</A>' >> /tmp/httpd/tmppage.html
  146. echo '<A HREF="/tmp/httpd/tmppage.html#U">U</A> <A HREF="/tmp/httpd/tmppage.html#V">V</A> <A HREF="/tmp/httpd/tmppage.html#W">W</A> <A HREF="/tmp/httpd/tmppage.html#X">X</A>' >> /tmp/httpd/tmppage.html
  147. echo '<A HREF="/tmp/httpd/tmppage.html#Y">Y</A> <A HREF="/tmp/httpd/tmppage.html#Z">Z</A>' >> /tmp/httpd/tmppage.html
  148. echo '</FONT></B>' >> /tmp/httpd/tmppage.html
  149. echo '<hr>' >> /tmp/httpd/tmppage.html
  150.  
  151. endif
  152.  
  153. nawk -F^ ' BEGIN {i=65;s=0;letter ="^A.*";rletter = "A"} {\
  154. comp = $1;$7 = $1;href = gsub (/ /,"",$7) \
  155. if ( comp !~ letter ) {\
  156. for ( x=i;x<=100; ++x ){\
  157. letter = sprintf("^%c.*", x)\
  158. rletter = sprintf("%c", x)\
  159. if ( comp ~ letter ) {i=x;s=0;break}\
  160. }\
  161. }\
  162. if ( comp ~ letter && s==0 ) {\
  163. print "<DT><A NAME=\""rletter"\"><B>"rletter"</B><DD></A><a href=http://localhost:7999/"$3" <b><b>"$1"</b></b></a>"$2"<br>";s=2 \
  164. }\
  165. if ( comp ~ letter && s==1) {\
  166. print "      <DD><a href=http://localhost:7999/"$3" <b><b>"$1"</b></b></a>"$2"<br>"\
  167. }\
  168. s=1\
  169. }' /tmp/httpd/top.sort  >> /tmp/httpd/tmppage.html
  170.  
  171. endif
  172.  
  173. cat tail.html >> /tmp/httpd/tmppage.html
  174.  
  175.  
  176. exit 0
  177.